
GO
----------------------------------CONGTY---------------------------------
ALTER PROCEDURE spCongTy_GetAllAvailable
@Lang varchar(50),
@PortalID int
AS
SELECT * FROM dbo.CMS_CongTy
WHERE Lang = @Lang AND TrangThai = 1 AND PortalID = @PortalID
ORDER BY ThuTu ASC, CreateDate DESC

GO

ALTER PROCEDURE spCongTy_GetAll
@Lang varchar(50),
@PortalID int
AS
SELECT * FROM dbo.CMS_CongTy
WHERE Lang = @Lang AND PortalID = @PortalID
ORDER BY ThuTu ASC, CreateDate DESC

GO

ALTER PROCEDURE spCongTy_GetAllByFilter
@Lang varchar(50),
@Filter bit,
@PortalID int
AS
BEGIN
	SELECT * FROM dbo.CMS_CongTy
	WHERE Lang = @Lang and TrangThai = @Filter and PortalID=@PortalID
	ORDER BY ThuTu ASC, CreateDate DESC
END
GO

ALTER PROCEDURE dbo.spCongTy_SetIndex
	@CONGTYID	int,
	@Index 	int
AS
UPDATE dbo.CMS_CongTy SET ThuTu = @Index  WHERE CongTyID = @CONGTYID

GO

ALTER PROCEDURE dbo.spCongTy_SetStatus
	@CONGTYID	int,
	@Status 	int
AS
UPDATE dbo.CMS_CongTy SET TrangThai = @Status  WHERE CongTyID = @CONGTYID

GO

ALTER PROCEDURE [dbo].[spCongTy_Insert]
(
	@TieuDe nvarchar(250),	
	@NoiDung ntext,
	@AnhDaiDien nvarchar(250),
	@TrangThai bit,
	@ThuTu int,
	--@CreateDate datetime,	
	--@ModifyDate datetime,
	@CreateUserID int,
	--@ModifyUserID int,
	@PortalID int,
	@Lang varchar(50)

)
AS
INSERT INTO CMS_CongTy
(
	TieuDe,
	NoiDung,
	AnhDaiDien,
	TrangThai,
	ThuTu,
	CreateDate,
	--ModifyDate,
	CreateUserID,
	--ModifyUserID,
	PortalID,
	Lang
)
VALUES 
(
	@TieuDe,
	@NoiDung,
	@AnhDaiDien,
	@TrangThai,
	@ThuTu,
	GETDATE(),
	--@ModifyDate,
	@CreateUserID,
	--@ModifyUserID,
	@PortalID,
	@Lang

)
DECLARE @RETURN_ID INT
SET @RETURN_ID = SCOPE_IDENTITY()
SELECT @RETURN_ID

GO

ALTER PROCEDURE [dbo].[spCongTy_Update]
(
	@CongTyID int,
	@TieuDe nvarchar(250),	
	@NoiDung ntext,
	@AnhDaiDien nvarchar(250),
	@TrangThai bit,
	@ThuTu int,	
	--@ModifyDate datetime,
	@ModifyUserID int,
	@PortalID int,
	@Lang varchar(50)	
)
AS
UPDATE dbo.CMS_CongTy SET
	TieuDe = @TieuDe,
	NoiDung = @NoiDung,
	AnhDaiDien = @AnhDaiDien,
	TrangThai = @TrangThai,
	ThuTu = @ThuTu,
	ModifyDate = GETDATE(),
	ModifyUserID = @ModifyUserID,
	PortalID = @PortalID,
	Lang = @Lang	

WHERE CongTyID = @CongTyID

GO

ALTER PROCEDURE [dbo].spCongTy_Delete
@CongTyID int
AS
BEGIN
	SET NOCOUNT ON;

delete dbo.CMS_CongTy
 where CongTyID = @CongTyID

END

GO

ALTER PROCEDURE spCongTy_GetInfo
@CongTyID int
AS
SELECT * FROM dbo.CMS_CongTy
WHERE CongTyID = @CongTyID

GO
-----------------------------------END CONGTY-----------------------------

